#!/bin/bash

echo "Starting Windows Authentication Service..."
echo

# 检查Java版本
if ! command -v java &> /dev/null; then
    echo "Error: Java is not installed or not in PATH"
    echo "Please install Java 11 or higher"
    exit 1
fi

# 检查Maven
if ! command -v mvn &> /dev/null; then
    echo "Error: Maven is not installed or not in PATH"
    echo "Please install Maven 3.6 or higher"
    exit 1
fi

# 创建日志目录
mkdir -p logs

# 编译项目
echo "Compiling project..."
mvn clean compile
if [ $? -ne 0 ]; then
    echo "Error: Failed to compile project"
    exit 1
fi

# 启动应用程序
echo "Starting application on port 8080..."
echo "Access the application at: http://localhost:8080"
echo "Press Ctrl+C to stop the application"
echo

mvn exec:java -Dexec.mainClass="io.vertx.core.Launcher" -Dexec.args="run com.example.auth.MainVerticle"